using Digitalmes.Common.Enums;

namespace Digitalmes.Domain.Sys;

/// <summary>
/// 日志记录
/// </summary>
[SugarTable("sys_log", "日志记录")]
public class SysLog : EntityTenantId
{
    /// <summary>
    /// 日志级别
    /// </summary>
    [SugarColumn(ColumnDescription = "日志级别")]
    public LogEnum Level { get; set; }

    /// <summary>
    /// 日志类型  1=登录  2=操作
    /// </summary>
    [SugarColumn(ColumnDescription = "日志类型  1=登录  2=操作")]
    public LogTypeEnum LogType { get; set; }

    /// <summary>
    /// 操作模块
    /// </summary>
    [SugarColumn(ColumnDescription = "操作模块", Length = 128)]
    public string? Module { get; set; }

    /// <summary>
    /// 操作类型:例如添加、修改
    /// </summary>
    [SugarColumn(ColumnDescription = "操作类型", Length = 16)]
    public string? OperateType { get; set; }

    /// <summary>
    /// 提交类型：get/post/delete
    /// </summary>
    [SugarColumn(ColumnDescription = "提交类型", Length = 16)]
    public string? Method { get; set; }

    /// <summary>
    /// 操作人
    /// </summary>
    [SugarColumn(ColumnDescription = "操作人", Length = 64)]
    public string? OperateUser { get; set; }

    /// <summary>
    /// IP
    /// </summary>
    [SugarColumn(ColumnDescription = "IP", Length = 64)]
    public string? IP { get; set; }

    /// <summary>
    /// 请求参数
    /// </summary>
    [SugarColumn(ColumnDescription = "请求参数", Length = 2048)]
    public string? Parameters { get; set; }

    /// <summary>
    /// 操作地址
    /// </summary>
    [SugarColumn(ColumnDescription = "操作地址", Length = 512)]
    public string? Address { get; set; }

    /// <summary>
    /// 操作状态
    /// </summary>
    [SugarColumn(ColumnDescription = "操作状态")]
    public bool Status { get; set; } = true;

    /// <summary>
    /// 详细信息
    /// </summary>
    [SugarColumn(ColumnDescription = "详细信息", Length = 2048)]
    public string? Message { get; set; }

    /// <summary>
    /// 返回结果
    /// </summary>
    [SugarColumn(ColumnDescription = "返回结果", Length = 2048)]
    public string? ReturnValue { get; set; }

    /// <summary>
    /// 操作时间
    /// </summary>
    [SugarColumn(ColumnDescription = "操作时间")]
    public DateTime OperateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 浏览器信息
    /// </summary>
    [SugarColumn(ColumnDescription = "浏览器信息", Length = 512)]
    public string? Browser { get; set; }

    /// <summary>
    /// 执行时长
    /// </summary>
    [SugarColumn(ColumnDescription = "执行时长")]
    public int ExecutionDuration { get; set; }
}
